<!DOCTYPE html>
<%@ page language="java" import="com.compuvest.web.*,java.util.*" pageEncoding="UTF-8" %>

<%@ taglib uri="/WEB-INF/tld/head.tld" prefix="head" %>
<%@ taglib uri="/WEB-INF/tld/extmenu.tld" prefix="menu" %>
<%@ taglib uri="/WEB-INF/tld/items.tld" prefix="itemstld" %>
<%@ taglib uri="/WEB-INF/tld/preference.tld" prefix="preference" %>

<jsp:useBean id="sb" class="SQLBean" scope="application"/>
<jsp:useBean id="advertShow" class="AdvertShow" scope="application"/>
<jsp:useBean id="basket" class="Basket" scope="session"/>
<%
    String thisURL = application.getInitParameter("http") + "ItemsBrand.jsp";

    int categoryID = advertShow.getInt(request.getParameter("cid"), 0);
    int subcatID = advertShow.getInt(request.getParameter("sid"), 0);
    int pageNo = advertShow.getInt(request.getParameter("pg"), 0);
    int sortID = advertShow.getInt(request.getParameter("srt"), 3);

    String brand = advertShow.getString(request.getParameter("brn"), "");

    session.setAttribute("session.categoryID", Integer.toString(categoryID));
    session.setAttribute("session.subcatID", Integer.toString(subcatID));

    // preference
    PreferenceUtil prefUtil = new PreferenceUtil(request, subcatID);

    Items tempItems = sb.getBrands(categoryID, subcatID, sortID, brand, prefUtil.getContent(), pageNo);
%>
<html>
<head>
<title><%= application.getInitParameter("CompanyName") %></title>
<%@include file="./incl/scripts.txt" %>
</head>
<body>

<div id='cvbody'>

 <head:show />

 <div id='cvcont'>
  <table id='cvmain'>
  <colgroup><col width='200px'/><col width='*'/><col width='160px'/></colgroup>
  <tbody>
   <tr>
    <td id='cvleft' valign="top">

<menu:extmenu
 categoryID='<%= categoryID %>'
 subcategoryID='<%= subcatID %>'
 pageUrl='<%= thisURL + "?pg=0&srt=" + sortID + "&brn=" + brand %>'
 categories='<%= tempItems.getCategories() %>'
 subcategories='<%= tempItems.getSubcategories() %>'/>

    </td>
    <td id='cvcenter' align="center" valign="top">

<%
    if(brand.length() == 0) {
	out.write(advertShow.getBrandPage());
    }
    else { // Navigation
	StringBuilder navig = new StringBuilder(400);
	navig.append("<div id='cv_nav'>&#8226; ");
	navig.append("<a href='").append(thisURL).append("'>Brand</a> &#8226; ");
	navig.append("<a href='").append(thisURL).append("?brn=").append(brand).append("'>").append(brand).append("</a>");
	navig.append("</div>");
	out.write(navig.toString());
    }
%>

<form name='SortForm' action='<%= thisURL %>' method="POST">
<input type='hidden' name='pg' value='0'/>
<input type='hidden' name='cid' value='<%= categoryID %>'/>
<input type='hidden' name='sid' value='<%= subcatID %>'/>
<input type='hidden' name='brn' value='<%= brand %>'/>
<%= prefUtil.getHiddenTags() %>

<itemstld:show
 categoryID='<%= categoryID %>'
 subcategoryID='<%= subcatID %>'
 pageNo='<%= pageNo %>'
 pageUrl='<%= thisURL + "?cid=" + categoryID + "&sid=" + subcatID + "&brn=" + brand + prefUtil.getLink() %>'
 reseller='<%= basket.getReseller() %>'
 items='<%= tempItems %>'
 sortID='<%= sortID %>'
 tailShow='false'
/>

</form>

    </td>
    <td id='cvright' valign="top">

     <div id='advright'></div>

<%
    if(subcatID != 0) {
%>
<preference:show
 pageUrl='<%= thisURL + "?cid=" +categoryID + "&sid=" + subcatID + "&srt=" + sortID + "&brn=" + brand %>'
 preferenceList='<%= tempItems.getPreference() %>'
 popUrl='<%= prefUtil.getLink() %>'
 popData='<%= prefUtil.getContent() %>'
/>
<%
    }
%>

    </td>
   </tr>
  </tbody>
  </table>
 </div>

 <div id='cvfoot'></div>
</div>

</body>
</html>
